package com.bingquan.java.swing;

import org.sikuli.script.FindFailed;
import org.sikuli.script.Image;
import org.sikuli.script.Pattern;
import org.sikuli.script.Screen;

public class sikuliTest {

    public static void main(String[] args) throws FindFailed {

        System.setProperty("TESSDATA_PREFIX", "C:\\Users\\陈兵权\\AppData\\Roaming\\Sikulix\\SikulixTesseract");

//        Screen s = new Screen();
//        // 设置未找到元素，自动等待时间10秒
//        s.setAutoWaitTimeout(10);
//        // 定义图片存放路径
//        String path = "C:\\Users\\陈兵权\\Desktop\\sikuli\\";
//
//        // 1. 双击桌面chrome浏览器图标
//        s.doubleClick(path + "chrome1");
//        // 2. 点击打开百度搜索
//        s.click(path + "chrome2");
//        // 3. 在搜索框中输入内容
//        s.type(path + "chrome3", "beijingtianqi ");
//        // 4. 点击搜索
//        s.click(path + "chrome4");

        Screen s = new Screen();
        try {
            s.doubleClick("D:\\imgs\\chrome1.png");
//            s.click("D:\\gitee_code\\gateway-nacos-swagger\\java-swing\\src\\main\\java\\com\\bingquan\\java\\swing\\imgs/chrome2.png");
//            s.type("D:\\gitee_code\\gateway-nacos-swagger\\java-swing\\src\\main\\java\\com\\bingquan\\java\\swing\\imgs/chrome3.png", "beijingtianqi ");
//            s.click("D:\\gitee_code\\gateway-nacos-swagger\\java-swing\\src\\main\\java\\com\\bingquan\\java\\swing\\imgs/chrome4.png");
        } catch (FindFailed e) {
            e.printStackTrace();
        }
    }

    private boolean isPicEXIST(String picPath) {
        Pattern pattern = new Pattern(picPath);
        Screen screen = new Screen();
        try {
            Image image = screen.find(pattern).getImage();
        } catch (FindFailed findFailed) {
            return false;
        }
        return true;
    }

}

